/*
 * FIR Coefficients for processing
 *
 * STM32-SDR: A software defined HAM radio embedded system.
 * Copyright (C) 2013, STM32-SDR Group
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include	"arm_math.h"
#include	"FIR_Coefficients.h"

//chh PSK Filter Coefficients
q15_t Dec4LPCoef[ 35 ] = {
		32767 *  -0.00021203644,
		32767 *  -0.00070252426,
		32767 *   -0.0016680526,
		32767 *   -0.0031934799,
		32767 *   -0.0051899752,
		32767 *   -0.0072862086,
		32767 *   -0.0087714235,
		32767 *   -0.0086272102,
		32767 *   -0.0056735648,
		32767 *    0.0011784719,
		32767 *      0.01261353,
		32767 *     0.028615709,
		32767 *     0.048280707,
		32767 *     0.069812051,
		32767 *     0.090735013,
		32767 *      0.10830381,
		32767 *      0.12001897,
		32767 *      0.12413413,
		32767 *      0.12001897,
		32767 *      0.10830381,
		32767 *     0.090735013,
		32767 *     0.069812051,
		32767 *     0.048280707,
		32767 *     0.028615709,
		32767 *      0.01261353,
		32767 *    0.0011784719,
		32767 *   -0.0056735648,
		32767 *   -0.0086272102,
		32767 *   -0.0087714235,
		32767 *   -0.0072862086,
		32767 *   -0.0051899752,
		32767 *   -0.0031934799,
		32767 *   -0.0016680526,
		32767 *  -0.00070252426,
		32767 *  -0.00021203644
};

/*======================================================================*/

q15_t 	FIRBitCoef[ 65 ] = {
		32767 *  4.34544353312181E-005,
		32767 * -4.91233963259580E-004,
		32767 * -7.87728675226019E-004,
		32767 * -1.35080960413432E-003,
		32767 * -2.12882395022525E-003,
		32767 * -3.13352868120857E-003,
		32767 * -4.36690434541042E-003,
		32767 * -5.81133495736277E-003,
		32767 * -7.42514606134644E-003,
		32767 * -9.14007102453525E-003,
		32767 * -1.08603737736329E-002,
		32767 * -1.24643348445605E-002,
		32767 * -1.38080486055754E-002,
		32767 * -1.47314854128492E-002,
		32767 * -1.50673587706280E-002,
		32767 * -1.46511869827097E-002,
		32767 * -1.33336912187397E-002,
		32767 * -1.09918793481672E-002,
		32767 * -7.54327547013411E-003,
		32767 * -2.95284395921849E-003,
		32767 *  2.75468424256632E-003,
		32767 *  9.49346738507647E-003,
		32767 *  1.71136504677581E-002,
		32767 *  2.54040194354235E-002,
		32767 *  3.41003627164679E-002,
		32767 *  4.28966968548455E-002,
		32767 *  5.14596043337083E-002,
		32767 *  5.94460415073074E-002,
		32767 *  6.65223329686451E-002,
		32767 *  7.23830650097610E-002,
		32767 *  7.67692292833128E-002,
		32767 *  7.94832082001426E-002,
		32767 *  8.04019187845638E-002,
		32767 *  7.94832082001426E-002,
		32767 *  7.67692292833128E-002,
		32767 *  7.23830650097610E-002,
		32767 *  6.65223329686451E-002,
		32767 *  5.94460415073074E-002,
		32767 *  5.14596043337083E-002,
		32767 *  4.28966968548455E-002,
		32767 *  3.41003627164679E-002,
		32767 *  2.54040194354235E-002,
		32767 *  1.71136504677581E-002,
		32767 *  9.49346738507647E-003,
		32767 *  2.75468424256632E-003,
		32767 * -2.95284395921849E-003,
		32767 * -7.54327547013411E-003,
		32767 * -1.09918793481672E-002,
		32767 * -1.33336912187397E-002,
		32767 * -1.46511869827097E-002,
		32767 * -1.50673587706280E-002,
		32767 * -1.47314854128492E-002,
		32767 * -1.38080486055754E-002,
		32767 * -1.24643348445605E-002,
		32767 * -1.08603737736329E-002,
		32767 * -9.14007102453525E-003,
		32767 * -7.42514606134644E-003,
		32767 * -5.81133495736277E-003,
		32767 * -4.36690434541042E-003,
		32767 * -3.13352868120857E-003,
		32767 * -2.12882395022525E-003,
		32767 * -1.35080960413432E-003,
		32767 * -7.87728675226019E-004,
		32767 * -4.91233963259580E-004,
		32767 *  4.34544353312181E-005
};

/*======================================================================*/

q15_t FIRFreqCoef[ 65 ] = {
		32767 *  -8.82290884173488E-004,
		32767 *  -1.13743887320639E-003,
		32767 *  -1.64128678489465E-003,
		32767 *  -2.05209889086253E-003,
		32767 *  -2.21756176327389E-003,
		32767 *  -1.97911605963953E-003,
		32767 *  -1.20579524827142E-003,
		32767 *   1.65272511919182E-004,
		32767 *   2.09434721909167E-003,
		32767 *   4.41226679403865E-003,
		32767 *   6.81893708889913E-003,
		32767 *   8.90459330660423E-003,
		32767 *   1.02036776754177E-002,
		32767 *   1.02663164627312E-002,
		32767 *   8.75074508195768E-003,
		32767 *   5.51366833309811E-003,
		32767 *   6.86162420348332E-004,
		32767 *  -5.28831303658911E-003,
		32767 *  -1.16532489911285E-002,
		32767 *  -1.73997493974992E-002,
		32767 *  -2.13766417901555E-002,
		32767 *  -2.24353771237607E-002,
		32767 *  -1.96068732388393E-002,
		32767 *  -1.22636654593710E-002,
		32767 *  -2.60786710341817E-004,
		32767 *   1.59860884681409E-002,
		32767 *   3.54913904978846E-002,
		32767 *   5.67733050444888E-002,
		32767 *   7.80023915048147E-002,
		32767 *   9.72073643477517E-002,
		32767 *   1.12514131590886E-001,
		32767 *   1.22377761748080E-001,
		32767 *   1.25803660705561E-001,
		32767 *   1.22377761748080E-001,
		32767 *   1.12514131590886E-001,
		32767 *   9.72073643477517E-002,
		32767 *   7.80023915048147E-002,
		32767 *   5.67733050444888E-002,
		32767 *   3.54913904978846E-002,
		32767 *   1.59860884681409E-002,
		32767 *  -2.60786710341817E-004,
		32767 *  -1.22636654593710E-002,
		32767 *  -1.96068732388393E-002,
		32767 *  -2.24353771237607E-002,
		32767 *  -2.13766417901555E-002,
		32767 *  -1.73997493974992E-002,
		32767 *  -1.16532489911285E-002,
		32767 *  -5.28831303658911E-003,
		32767 *   6.86162420348332E-004,
		32767 *   5.51366833309811E-003,
		32767 *   8.75074508195768E-003,
		32767 *   1.02663164627312E-002,
		32767 *   1.02036776754177E-002,
		32767 *   8.90459330660423E-003,
		32767 *   6.81893708889913E-003,
		32767 *   4.41226679403865E-003,
		32767 *   2.09434721909167E-003,
		32767 *   1.65272511919182E-004,
		32767 *  -1.20579524827142E-003,
		32767 *  -1.97911605963953E-003,
		32767 *  -2.21756176327389E-003,
		32767 *  -2.05209889086253E-003,
		32767 *  -1.64128678489465E-003,
		32767 *  -1.13743887320639E-003,
		32767 *  -8.82290884173488E-004
};


//////////////////////////////////////////////////////////////////////
q15_t	coeff_fir_I[NUM_FIR_COEF] = {
		0,
		-11,
		-15,
		-4,
		-19,
		4,
		-19,
		15,
		-15,
		25,
		-5,
		33,
		11,
		34,
		32,
		25,
		52,
		4,
		65,
		-28,
		64,
		-66,
		42,
		-100,
		-1,
		-118,
		-60,
		-108,
		-125,
		-64,
		-177,
		15,
		-197,
		116,
		-169,
		219,
		-85,
		295,
		50,
		314,
		215,
		254,
		376,
		105,
		488,
		-124,
		504,
		-399,
		389,
		-666,
		122,
		-856,
		-293,
		-889,
		-821,
		-681,
		-1408,
		-134,
		-1980,
		926,
		-2460,
		3095,
		-2779,
		11925,
		16384,
		-11926,
		-2779,
		-3096,
		-2460,
		-927,
		-1980,
		133,
		-1408,
		680,
		-821,
		888,
		-293,
		855,
		122,
		665,
		389,
		398,
		504,
		123,
		488,
		-106,
		376,
		-255,
		215,
		-315,
		50,
		-296,
		-85,
		-220,
		-169,
		-117,
		-197,
		-16,
		-177,
		63,
		-125,
		107,
		-60,
		117,
		-1,
		99,
		42,
		65,
		64,
		27,
		65,
		-5,
		52,
		-26,
		32,
		-35,
		11,
		-34,
		-5,
		-26,
		-15,
		-16,
		-19,
		-5,
		-19,
		3,
		-15,
		0
};
//////////////////////////////////////////////////////////////////////
q15_t 	coeff_fir_Q[NUM_FIR_COEF] = {
		0,
		-11,
		14,
		-4,
		18,
		4,
		18,
		15,
		14,
		25,
		4,
		33,
		-12,
		34,
		-33,
		25,
		-53,
		4,
		-66,
		-28,
		-65,
		-66,
		-43,
		-100,
		0,
		-118,
		59,
		-108,
		124,
		-64,
		176,
		15,
		196,
		116,
		168,
		219,
		84,
		295,
		-51,
		314,
		-216,
		254,
		-377,
		105,
		-489,
		-124,
		-505,
		-399,
		-390,
		-666,
		-123,
		-856,
		292,
		-889,
		820,
		-681,
		1407,
		-134,
		1979,
		926,
		2459,
		3095,
		2778,
		11925,
		-16384,
		-11926,
		2778,
		-3096,
		2459,
		-927,
		1979,
		133,
		1407,
		680,
		820,
		888,
		292,
		855,
		-123,
		665,
		-390,
		398,
		-505,
		123,
		-489,
		-106,
		-377,
		-255,
		-216,
		-315,
		-51,
		-296,
		84,
		-220,
		168,
		-117,
		196,
		-16,
		176,
		63,
		124,
		107,
		59,
		117,
		0,
		99,
		-43,
		65,
		-65,
		27,
		-66,
		-5,
		-53,
		-26,
		-33,
		-35,
		-12,
		-34,
		4,
		-26,
		14,
		-16,
		18,
		-5,
		18,
		3,
		14,
		0
};

const q15_t post_FILT_Coeff[125][5] = {
/*  		BP300-3K 	BP300-2.7K		BP300-1.3K      BP400-700      BP500-600 */
		{       8,       34,              12,              8,            -5},
		{      46,       46,              14,            -10,             4},
		{      37,        0,              35,            -17,            -4},
		{     -19,        0,              37,            -25,           -10},
		{      25,       32,              14,            -29,           -15},
		{       4,      -15,             -13,            -27,           -17},
		{     -14,        1,             -23,            -18,           -15},
		{      24,       20,              -8,             -5,            -6},
		{     -36,      -40,              15,              9,            10},
		{      -6,       -8,              15,             18,            31},
		{      -8,        0,             -20,             18,            54},
		{     -69,      -74,             -65,              9,            71},
		{       4,      -18,             -77,             -5,            76},
		{     -74,      -26,             -45,            -15,            64},
		{     -63,     -110,              -5,            -12,            33},
		{     -15,      -20,             -12,              8,           -14},
		{    -130,      -54,             -74,             47,           -69},
		{     -17,     -135,            -133,             93,          -120},
		{     -76,       -3,            -124,            133,          -155},
		{    -115,      -75,             -46,            149,          -162},
		{      25,     -132,              25,            131,          -136},
		{    -139,       41,              10,             76,           -78},
		{      -5,      -79,             -79,             -3,             0},
		{      13,      -90,            -137,            -84,            82},
		{    -115,      114,             -76,           -144,           149},
		{     140,      -64,              74,           -163,           186},
		{     -44,       -4,             177,           -138,           184},
		{      51,      210,             133,            -83,           145},
		{     210,      -35,               0,            -26,            83},
		{     -50,      118,             -49,              1,            17},
		{     296,      308,              87,            -26,           -33},
		{     144,       -5,             311,           -106,           -51},
		{      97,      259,             408,           -218,           -33},
		{     442,      375,             276,           -316,            10},
		{      20,        2,              58,           -351,            55},
		{     369,      389,              14,           -288,            75},
		{     329,      372,             231,           -120,            44},
		{       7,      -38,             502,            120,           -50},
		{     556,      475,             516,            370,          -198},
		{     -13,      259,             204,            557,          -367},
		{     187,     -143,            -149,            621,          -508},
		{     385,      486,            -180,            544,          -567},
		{    -340,        8,             144,            357,          -497},
		{     390,     -317,             436,            137,          -279},
		{    -219,      406,             274,            -22,            71},
		{    -378,     -396,            -318,            -44,           497},
		{     248,     -541,            -825,             96,           911},
		{    -969,      237,            -755,            351,          1212},
		{    -123,     -945,            -213,            606,          1307},
		{    -514,     -767,             121,            715,          1140},
		{   -1341,        3,            -327,            551,           706},
		{      28,    -1625,           -1333,             55,            66},
		{   -1738,     -909,           -1972,           -721,          -669},
		{    -943,     -257,           -1539,          -1618,         -1351},
		{    -547,    -2445,            -419,          -2394,         -1829},
		{   -2723,     -809,              87,          -2798,         -1985},
		{     123,     -493,            -981,          -2638,         -1762},
		{   -2379,    -3575,           -3030,          -1855,         -1181},
		{   -2314,       -7,           -4024,           -553,          -340},
		{    1257,     -658,           -2111,           1017,           600},
		{   -6846,    -6617,            2564,           2508,          1454},
		{    5111,     6762,            7530,           3575,          2048},
		{   23585,    21128,            9657,           3962,          2261},
		{    5111,     6762,            7530,           3575,          2048},
		{   -6846,    -6617,            2564,           2508,          1454},
		{    1257,     -658,           -2111,           1017,           600},
		{   -2314,       -7,           -4024,           -553,          -340},
		{   -2379,    -3575,           -3030,          -1855,         -1181},
		{     123,     -493,            -981,          -2638,         -1762},
		{   -2723,     -809,              87,          -2798,         -1985},
		{    -547,    -2445,            -419,          -2394,         -1829},
		{    -943,     -257,           -1539,          -1618,         -1351},
		{   -1738,     -909,           -1972,           -721,          -669},
		{      28,    -1625,           -1333,             55,            66},
		{   -1341,        3,            -327,            551,           706},
		{    -514,     -767,             121,            715,          1140},
		{    -123,     -945,            -213,            606,          1307},
		{    -969,      237,            -755,            351,          1212},
		{     248,     -541,            -825,             96,           911},
		{    -378,     -396,            -318,            -44,           497},
		{    -219,      406,             274,            -22,            71},
		{     390,     -317,             436,            137,          -279},
		{    -340,        8,             144,            357,          -497},
		{     385,      486,            -180,            544,          -567},
		{     187,     -143,            -149,            621,          -508},
		{     -13,      259,             204,            557,          -367},
		{     556,      475,             516,            370,          -198},
		{       7,      -38,             502,            120,           -50},
		{     329,      372,             231,           -120,            44},
		{     369,      389,              14,           -288,            75},
		{      20,        2,              58,           -351,            55},
		{     442,      375,             276,           -316,            10},
		{      97,      259,             408,           -218,           -33},
		{     144,       -5,             311,           -106,           -51},
		{     296,      308,              87,            -26,           -33},
		{     -50,      118,             -49,              1,            17},
		{     210,      -35,               0,            -26,            83},
		{      51,      210,             133,            -83,           145},
		{     -44,       -4,             177,           -138,           184},
		{     140,      -64,              74,           -163,           186},
		{    -115,      114,             -76,           -144,           149},
		{      13,      -90,            -137,            -84,            82},
		{      -5,      -79,             -79,             -3,             0},
		{    -139,       41,              10,             76,           -78},
		{      25,     -132,              25,            131,          -136},
		{    -115,      -75,             -46,            149,          -162},
		{     -76,       -3,            -124,            133,          -155},
		{     -17,     -135,            -133,             93,          -120},
		{    -130,      -54,             -74,             47,           -69},
		{     -15,      -20,             -12,              8,           -14},
		{     -63,     -110,              -5,            -12,            33},
		{     -74,      -26,             -45,            -15,            64},
		{       4,      -18,             -77,             -5,            76},
		{     -69,      -74,             -65,              9,            71},
		{      -8,        0,             -20,             18,            54},
		{      -6,       -8,              15,             18,            31},
		{     -36,      -40,              15,              9,            10},
		{      24,       20,              -8,             -5,            -6},
		{     -14,        1,             -23,            -18,           -15},
		{       4,      -15,             -13,            -27,           -17},
		{      25,       32,              14,            -29,           -15},
		{     -19,        0,              37,            -25,           -10},
		{      37,        0,              35,            -17,            -4},
		{      46,       46,              14,            -10,             4},
		{       8,       34,              12,              8,            -5}

};
